package com.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.ResourceBundle;

public class jedisUtil {
   static JedisPool pool;
    static {
        ResourceBundle bundle=ResourceBundle.getBundle("jedis");
        int maxTotal = Integer.parseInt(bundle.getString("jedis.maxTotal")) ;
        int maxWaitMillis =Integer.parseInt(bundle.getString("jedis.maxWaitMillis"))  ;
        String host = bundle.getString("jedis.host");
        int port =Integer.parseInt(bundle.getString("jedis.port"))  ;
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(maxTotal);
        config.setMaxWaitMillis(maxWaitMillis);
        pool=new JedisPool(config,host,port);
    }
    public static Jedis getjedis(){
        return pool.getResource();
    }
}
